<template>
  <div class="c-page">
    <div class="title">产能利用率</div>
    <div class="plan">
      <div class="item">
        <span>近30个工作日产能利用率</span>
      </div>
       <div class="item">
        <span>日平均39.4%</span>
      </div>
    </div>
    <div class="barChart" ref="barChart"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      myChart: null,
      chartOptions: {
        color: ["#2f89cf"],
        //表格大小
        grid: {
          left: "0%",
          top: "10px",
          right: "0%",
          bottom: "4%",
          containLabel: true,
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐标轴指示器，坐标轴触发有效,影子效果
            type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
          },
        },
        xAxis: [
          {
            type: "category",
            data: [
              "动作片",
              "动画片",
              "电视剧",
              "纪录片",
              "综艺片",
              "伦理片",
              "恐怖片",
            ],
            axisTick: {
              alignWithLabel: true,
            },
            axisLabel: {
              color: "rgba(255,255,255,.6)",
              fontSize: "12",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            axisLabel: {
              color: "rgba(255,255,255,.6)",
              fontSize: "12",
            },
            lineStyle: {
              color: "rgba(255,255,255,.1)",
              width: 1,
              type: "solid",
            },
            splitLine: {
              lineStyle: {
                color: "rgba(255,255,255,.1)",
              },
            },
          },
        ],
        series: [
          {
            name: "直接访问",
            type: "bar",
            itemStyle: {
                color: new this.$echarts.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                        {offset: 0, color: '#83bff6'},
                        {offset: 0.5, color: '#188df0'},
                        {offset: 1, color: '#188df0'}
                    ]
                )
            },
            barWidth: "40%",
            data: [10, 52, 200, 334, 390, 330, 220],
          },
        ],
      },
    }
  },
    mounted() {
    this.createEchart();
  },
  methods: {
    createEchart() {
      this.myChart = this.$echarts
        .init(this.$refs.barChart)
        .setOption(this.chartOptions);
      window.addEventListener("resize", () => {
        this.myChart.resize();
      });
    },
  },
}
</script>
<style lang="less" scoped>
.c-page {
  width: 100%;
  height: 100%;
  padding: 5px;
  cursor: pointer;
  display: flex;
  flex-flow: column;
  .title {
    border-left: 3px solid #1CB9FC;
    padding: 5px;
    text-align: left;
    font-size: 14px;
    width: 40%;
    background-image: linear-gradient(to right, #1CB9FC , #050D3E);
  }
  .barChart {
    height: 100%;
    width: 100% ;
  }
  .plan {
    color: #2ED1E0;
    font-size: 13px;
    display: flex;
    justify-content: flex-end;
    margin: 5px 0;
    .item {
      margin: 0 5px;
    }
  }

}
</style>